
var winW, winH;
$(function(){
	
	autosize();
    $(window).resize(function(){
	    autosize();
    })
    
	//导航
	jQuery("nav").slide({type:"menu", titCell:".menu", targetCell:".sub", effect:"slideDown", delayTime:300, triggerTime:0, defaultPlay:false, returnDefault:true});
	$("#fullfocus").slidesjs({
        width: 1920,
        height: 667,
		//第一张图开始播放
		start: 1, 
    });
    $("#fullfocus_phone").slidesjs({
        width: 640,
        height: 500,
		//第一张图开始播放
		start: 1, 
    });
    if (winW<767){
		$("#fullfocus").hide();
		$("#fullfocus_phone").show();
	}else{
		$("#fullfocus").show();
		$("#fullfocus_phone").hide();
	}
     
     
    
    jQuery(".product .sidebox").slide({
		titCell: ".hd",
		targetCell: ".bd",
		effect: "slideDown",
		defaultPlay: false,
		trigger: "click"
	});
	
	//console.log("123")
	
	//首页新闻
	$(".index-news .hd").click(function(){
		if ($(".index-news .bd").css("display")=="none"){
			$(".index-news .bd").show();
		}else{
			$(".index-news .bd").hide();
		}
	})
	$(".index-news .news-tip").click(function(){
		$(".index-news .hd").click();
	})
	
	
	//经销商登录
//	$(".login .input-code").blur(function(){
//		if ($(this).val()=="输入验证码"){
//			$(this).val("");
//		}
//	});
//	$(".login .input-code").focus(function(){
//		if ($(this).val()==""){
//			$(this).val("输入验证码");
//		}
//	});

	//加入我们
	jQuery('.slideTxtBox').slide({trigger:'click'});
	
	//新闻1
	$(".news01_list .menu_btn").click(function(){
		if($(".news01_list .menu").css("left") < "0px"){
			$(".news01_list .menu").css({"left":0})
		}else{
			$(".news01_list .menu").css({"left":-128})
		}
	})
	
	//品牌简介
	$(".intro_con .menu_btn").click(function(){
		if($(".intro_con .menu").css("left") < "0px"){
			$(".intro_con .menu").css({"left":0})
		}else{
			$(".intro_con .menu").css({"left":-260})
		}
	})
	//三包标准
	$(".norm_con .menu_btn").click(function(){
		if($(".norm_con .menu").css("left") < "0px"){
			$(".norm_con .menu").css({"left":0})
		}else{
			$(".norm_con .menu").css({"left":-260})
		}
	})
	//在线问答
	$(".qa_con .menu_btn").click(function(){
		if($(".qa_con .menu").css("left") < "0px"){
			$(".qa_con .menu").css({"left":0})
		}else{
			$(".qa_con .menu").css({"left":-260})
		}
	})
	
	
	//T2--选择配色
	$(".t2 .motor .circle-list span").click(function(){
		var color = $(this).attr("class");
		var motorImg,bgImg;
		if (color=="circle-white"){
			motorImg = "assets/images/product/T2/motor_white.png";
			bgImg = "assets/images/product/T2/motor_white_bg.png";
		}else if(color=="circle-gray"){
			motorImg = "assets/images/product/T2/motor_gray.png";
			bgImg = "assets/images/product/T2/motor_gray_bg.png";
		}else if(color=="circle-green"){
			motorImg = "assets/images/product/T2/motor_green.png";
			bgImg = "assets/images/product/T2/motor_green_bg.png";
		}else if(color=="circle-blue"){
			motorImg = "assets/images/product/T2/motor_blue.png";
			bgImg = "assets/images/product/T2/motor_blue_bg.png";
		}
		//$(".t2 .motor-img").attr("src",motorImg);
		//$(".t2 .motor").css("background","url("+bgImg+")");
		$(".t2 .motor-img").attr("src","/"+motorImg);
		$(".t2 .motor").css("background","url(/"+bgImg+")");
	})
	//T3--选择配色
	$(".t3 .motor .circle-list span").click(function(){
		var color = $(this).attr("class");
		var motorImg,bgImg;
		if (color=="circle-white"){
			motorImg = "assets/images/product/T3/motor_white.png";
			bgImg = "assets/images/product/T3/motor_white_bg.png";
		}else if(color=="circle-gray"){
			motorImg = "assets/images/product/T3/motor_gray.png";
			bgImg = "assets/images/product/T3/motor_gray_bg.png";
		}else if(color=="circle-green"){
			motorImg = "assets/images/product/T3/motor_green.png";
			bgImg = "assets/images/product/T3/motor_green_bg.png";
		}else if(color=="circle-red"){
			motorImg = "assets/images/product/T3/motor_red.png";
			bgImg = "assets/images/product/T3/motor_red_bg.png";
		}
		//$(".t3 .motor-img").attr("src",motorImg);
		//$(".t3 .motor").css("background","url("+bgImg+")");
		$(".t3 .motor-img").attr("src","/"+motorImg);
		$(".t3 .motor").css("background","url(/"+bgImg+")");
	})
	
	//尾部--二维码
	if (winW<767){
		$(".footer-container .wx-code").click(function(){
			if ($(".footer-container .code").css("display")=="none"){
				$(".footer-container .code").show();
			}else{
				$(".footer-container .code").hide();
			}
		})
	}else{
		$(".footer-container .wx-code").mouseenter(function(){
			$(".footer-container .code").show();
		}).mouseleave(function(){
			$(".footer-container .code").hide();
		});
	}
//	$(window).scroll( function() {
//		var scrollValue=$(window).scrollTop();
//		if (winW<767){
//			if (scrollValue > 216){
//				$('.intro_con .menu').css({"top":0});
//			}else{
//				$('.intro_con .menu').css({"top":216});
//			}
//		}else{
//			if (scrollValue > 466){
//				$('.intro_con .menu').css({"position":"relative","top":0});
//			}else{
//				$('.intro_con .menu').css({"position":"fixed","top":466});
//			}
//		}
//	});
	//alert($(window).width())
})

//屏幕自适应
function autosize(){
	winW = $(window).width();
	winH = $(window).height();
	$('.common_pic img').width(winW);
	
	//图片自适应
	//$('.common_pic').autoIMG();
	
	//首页焦点图
	if (winW<767){
		$("#fullfocus").hide();
		$("#fullfocus_phone").show();
	}else{
		$("#fullfocus").show();
		$("#fullfocus_phone").hide();
	}
	
}










